package com.wy.service;

import com.wy.mapper.UserMapper;
import com.wy.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @Author: wy
 * @Date:2019/10/29 16:14
 */
@Service
public class UserService {

    @Autowired
     private UserMapper userMapper;

    /**
     * 根据id查询
     * @param id
     * @return
     */
     public User findUser(Long id){
           return   userMapper.selectByPrimaryKey(id);
     }

    /**
     * 查询所有
     * @return
     */
    public List<User> findAll(){
         return userMapper.selectAll();
     }


    /**
     * 根据id删除
     * @param id
     */
    public void delete(Long id){
               userMapper.deleteByPrimaryKey(id);

     }
      public void update(User user){
               userMapper.updateByPrimaryKey(user);
      }

}
